from rest_framework.throttling import SimpleRateThrottle


class CustomRateThrottle(SimpleRateThrottle):
    scope = 'custom_rate'

    def get_cache_key(self, request, view):
        """
        key: "ip:url"
            127.0.0.1:/api/v1/posts/
        :param request:
        :param view:
        :return:
        """
        # return self.get_ident(request)
        return f"{self.get_ident(request)}:{request.path}"
